package com.example.hxds.mis.api.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.example.hxds.common.util.PageUtils;
import com.example.hxds.common.util.R;
import com.example.hxds.mis.api.controller.form.SearchDriverByPageForm;
import com.example.hxds.mis.api.controller.form.SearchDriverComprehensiveDataForm;
import com.example.hxds.mis.api.controller.form.UpdateDriverRealAuthForm;
import com.example.hxds.mis.api.service.DriverService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;

/**
 * @BelongsProject: hxds
 * @BelongsPackage: com.example.hxds.mis.api.controller
 * @Author: wanglansheng
 * @CreateTime: 2024-01-14  15:42
 * @Description: TODO
 * @Version: 1.0
 */
@RestController
@RequestMapping("/driver")
@Tag(name = "DriverController", description = "司机模块web接口")
public class DriverController {
    @Resource
    private DriverService driverService;

    @PostMapping("/searchDriverByPage")
    @SaCheckPermission(value = {"ROOT","DRIVER:SELECT"},mode = SaMode.OR)
    @Operation(summary = "查询司机分页数据")
    public R searchDriverByPage(@RequestBody @Valid SearchDriverByPageForm form){
        PageUtils pageUtils = driverService.searchDriverByPage(form);
        return R.ok().put("result",pageUtils);
    }
    @PostMapping("/searchDriverComprehensiveData")
    @SaCheckPermission(value = {"ROOT","ORIVER:SELECT"},mode = SaMode.OR)
    @Operation(summary = "查询司机综合数据")
    public R searchDriverComprehensiveData(@RequestBody @Valid SearchDriverComprehensiveDataForm form) {
        HashMap map = driverService.searchDriverComprehensiveData(form.getRealAuth(),form.getDriverId());
        return R.ok().put("result", map);
    }

    @PostMapping("updateDriverRealAtuh")
    @SaCheckPermission(value = {"ROOT","ORIVER:UPDATE"},mode = SaMode.OR)
    @Operation(summary = "更新司机实名认证状态")
    public R updateDriverRealAuth(@RequestBody @Valid UpdateDriverRealAuthForm form){
        int rows = driverService.updateDriverRealAuth(form);
        return  R.ok().put("rows", rows);
    }
}
